document.write('<scr'+'ipt language="javascript" src="https://static.cnstock.com/js/lib/func_qmt_author.js"></scr'+'ipt>');

    var column = $('#cms_output_columntype').html();
	var keywords = '';
	if (document.getElementsByName("keywords")[0] != undefined)
		keywords = document.getElementsByName("keywords")[0].content;
	keywords = $.trim(keywords);

	//公告解读详情页里挂行情图
	if ((column == 'ggjd' || column == 'company' || column == 'investor') && keywords != '')
	{
		var kw_arr = keywords.split(' ');
		var stockcode = '';
		for (i=0; i<kw_arr.length; i++)
		{
			keyword = $.trim(kw_arr[i]);
			if (keyword.length == 6 && checkStockcode(keyword))
			{
				stockcode = keyword;
				break;
			}
		}

		if (stockcode != '')
		{
			var html = '<div class="stock-info-block">'+
                       '<iframe width="562" height="300" frameborder="0" scrolling="no" src="https://app.cnstock.com/api/widgets/stock_info/'+stockcode+'"></iframe>'+
						'</div>';
			if (document.getElementById('output_hangqing_div') != undefined)
				$('#output_hangqing_div').html(html);
		}
	}
	
	//正文热词
	if (keywords != '')
	{
		var content = '';
		if (document.getElementById('qmt_content_div')  != undefined)
			content = document.getElementById('qmt_content_div').innerHTML;
		var kw_arr = keywords.split(' ');
		var k = '';
		for (i=0; i<kw_arr.length; i++)
		{
			keyword = $.trim(kw_arr[i]);
			if (keyword != '' && content.indexOf(keyword) > -1)
			{
				k += keyword + ' ';
			}
		}

		if (k != '')
		{
			$.ajax({
				type: 'get',
				url: appUrl+'/api/hotwords/get/?k='+encodeURIComponent(k),
				dataType: 'jsonp',
				jsonp: 'cb',
				success: function(data){
					if (data.msg != '') {
						kw_arr = (data.msg).split('|');
						for (i=0; i<kw_arr.length; i++) {
							k = kw_arr[i].split('#');
							keyword = k[0];
							if (k[1] == 'gp')
							{
								content = content.replace(keyword,'<a href="javascript:void();" onmouseover="showStockTip(\''+k[2]+'\',this);"><u><font color="#204281">'+keyword+'</font></u></a>');
							}
							else
							{
								url = 'https://caifu.cnstock.com/product/detail/fund/'+k[2]+'/';
								content = content.replace(keyword,'<a href="'+url+'" target="_blank"><u><font color="#204281">'+keyword+'</font></u></a>');
							}
						}
						document.getElementById('qmt_content_div').innerHTML = content;
					}
				}
			});
		}
	}

function checkStockcode(str)
{
  var regstr = /[^0-9]/gi;
  if (regstr.exec(str) != null)
    return false;
  else
    return true;
}


function showStockTip(code,thisobj)
{
        if(code && thisobj ){
            var tip = '';
            tip += '    <div class="cnstock-dialog" onmouseover="showStockTip();">';
            tip += '        <div class="inner">';
            tip += '            <div class="fn-clear">';
            tip += '                <div class="realtime">';
            tip += '                    <img src="https://img.hq.cnstock.com/WebHQ/WebHQ.dll/HisGif?Stkcode='+code+'&Style=4&time='+(Math.random())+'" height="186" height="126" alt="">';
            tip += '                </div>';
            tip += '                <div class="search-line">';
            tip += '                    <input type="text" class="txt" id="suggest_tip" placeholder="\u8bf7\u8f93\u5165\u4ee3\u7801\u6216\u7b80\u79f0">';
            tip += '                    <input type="button" onclick="dojumpcode(\'suggest_tip\');" class="btn" value="">';
            tip += '                </div>';
            tip += '            </div>';
            tip += '            <div class="fn-right">';
            tip += '                <a href="javascript:" class="add-stock" onclick="cnstock_add_stock(\''+code+'\')"></a>';
            tip += '                <div class="link">';
            tip += '                    <a href="https://irm.cnstock.com/company/index/'+code+'/" target="_blank">\u516c\u53f8\u4e3b\u9875</a>';   //公司主页
            tip += '                    <a href="https://t.cnstock.com/index.php?mod=qun&stockcode='+code+'" target="_blank">\u5fae \u80a1 \u5427</a>';   //微 股 吧
            tip += '                    <a href="https://irm.cnstock.com/ctdetail_company/index/'+code+'/zxdt" target="_blank">\u6700\u65b0\u52a8\u6001</a>';   //最新动态
            tip += '                    <a href="https://irm.cnstock.com/ctdetail_company/index/'+code+'/cwts" target="_blank">\u8d22\u52a1\u900f\u89c6</a>';   //财务透视
            tip += '                    <a href="https://irm.cnstock.com/ivlist_company/index/'+code+'/gsgg" target="_blank">\u516c\u53f8\u516c\u544a</a>';   //公司公告
            tip += '                    <a href="https://irm.cnstock.com/ctdetail_company/index/'+code+'/jyfx" target="_blank">\u7ecf\u8425\u5206\u6790</a>';   //经营分析
            tip += '                    <a href="https://irm.cnstock.com/ctdetail_company/index/'+code+'/zldx" target="_blank">\u4e3b\u529b\u52a8\u5411</a>';   //主力动向
            tip += '                </div>';
            tip += '            </div>';
            tip += '        </div>';
            tip += '    </div>';
            
            if (($('#stockTipDiv')).length > 0){
                $('#suggest_tips').unautocomplete();
                $('#stockTipDiv').remove();
            }
            
            var stockTipDiv = document.createElement('div');
            stockTipDiv.id = 'stockTipDiv';
            stockTipDiv.style.position = 'absolute';

            stockTipDiv.innerHTML = tip;
            document.getElementById('cnstock_common_footer').appendChild(stockTipDiv);
            stockTipDiv.style.left = $(thisobj).offset().left+'px';
            stockTipDiv.style.top = $(thisobj).offset().top + 18 + 'px';
            stockTipDiv.style.display = '';
            
            stockTipSuggest();
            return false;
        }else{
            
            $('#stockTipDiv').show();
            return false;
        }
}

function hideStockTip(){
    $('#stockTipDiv').hide();
    $('#suggest_tips').unautocomplete();
}


$(document).on('click','#stockTipDiv',function(e){
    //e.preventDefault();
    e.stopPropagation();
});
$(document).on('click',function(e){
    hideStockTip();
});

